
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class Language {

    public final static int    $   = GroupRoot.$LANGUAGE$;
    public final static String _   = "LANGUAGE$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
                                                .lang(Language.$EN_US, "language")
                                                .lang(Language.$ZH_CN, "语言组")
                                                .done();
    
    public final static int    $EN_US  = $ + 1;
    public final static String _EN_US  = "LANGUAGE$EN_US";
    @SystemData
    public final static Code   EN_US   = CodeBuilder.code($, $EN_US, _EN_US)
                                                   .lang(Language.$EN_US, "english(us)")
                                                   .lang(Language.$ZH_CN, "美国英语")
                                                   .done();
    public final static int    $ZH_CN  = $ + 2;
    public final static String _ZH_CN  = "LANGUAGE$ZH_CN";
    @SystemData
    public final static Code   ZH_CN   = CodeBuilder.code($, $ZH_CN, _ZH_CN)
                                                   .lang(Language.$EN_US, "chinese(simple)")
                                                   .lang(Language.$ZH_CN, "简体中文")
                                                   .done();
    public final static int    $ZH_TW  = $ + 3;
    public final static String _ZH_TW  = "LANGUAGE$ZH_TW";
    @SystemData
    public final static Code   ZH_TW   = CodeBuilder.code($, $ZH_TW, _ZH_TW)
                                                   .lang(Language.$EN_US, "chinese(traditional)")
                                                   .lang(Language.$ZH_CN, "繁体中文")
                                                   .done();
    public final static int    $JA_JP  = $ + 4;
    public final static String _JA_JP  = "LANGUAGE$JA_JP";
    @SystemData
    public final static Code   JA_JP   = CodeBuilder.code($, $JA_JP, _JA_JP)
                                                   .lang(Language.$EN_US, "japanese")
                                                   .lang(Language.$ZH_CN, "日语")
                                                   .done();
    public final static int    $KO_KR  = $ + 5;
    public final static String _KO_KR  = "LANGUAGE$KO_KR";
    @SystemData
    public final static Code   KO_KR   = CodeBuilder.code($, $KO_KR, _KO_KR)
                                                   .lang(Language.$EN_US, "korean")
                                                   .lang(Language.$ZH_CN, "韩语")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($EN_US == id) return true;
        if($ZH_CN == id) return true;
        if($ZH_TW == id) return true;
        if($JA_JP == id) return true;
        if($KO_KR == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($EN_US == id) return EN_US;
        if($ZH_CN == id) return ZH_CN;
        if($ZH_TW == id) return ZH_TW;
        if($JA_JP == id) return JA_JP;
        if($KO_KR == id) return KO_KR;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_EN_US.equals(key)) return EN_US;
        if(_ZH_CN.equals(key)) return ZH_CN;
        if(_ZH_TW.equals(key)) return ZH_TW;
        if(_JA_JP.equals(key)) return JA_JP;
        if(_KO_KR.equals(key)) return KO_KR;
        return null;
    }
}
